package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.project.bean.VoucherBean;
import com.project.bean.VoucherInfoBean;
import com.project.mapper.IVoucherInfoMapper;
import com.project.mapper.IVoucherMapper;
import com.project.service.IVoucherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class VoucherServiceImpl implements IVoucherService {

    @Autowired
    private IVoucherMapper voucherMapper;

    @Autowired
    private IVoucherInfoMapper voucherInfoMapper;
    @Override
    public void delByCode(String voucherId) {
        voucherMapper.deleteById(voucherId);
    }

//    @Override
//    public void addVoucher(VoucherBean voucherBean) {
//
//        voucherMapper.insert(voucherBean);
//    }


    public void addVoucher(VoucherBean voucherBean, List<VoucherInfoBean> voucherInfoBean){
        voucherMapper.insert(voucherBean);
        for(VoucherInfoBean  infoBean:voucherInfoBean){
            voucherInfoMapper.insert  (infoBean);
        }
    }
    @Override
    public VoucherBean findVoucherByCode(String userId) {
        return null;
    }
}
